package day06;

import java.util.Arrays;

/**
 * @author Huangjin
 * @version 1.0
 * describe:第二遍作业
 * @date 2023/2/17 17:51
 */
public class WorkTwo {
    public static void main(String[] args) {
        maxOfArray();
        say();
        sayHi("Mara");
        sayHello("Mara",10);
        int a = getNum();
        System.out.println(a);
        int b = plus(6,9);
        System.out.println(b);
        int[] c = testArray(20,100);
        for (int i:c){
            System.out.println(i);
        }
    }

    public static void maxOfArray(){
        int[] array = new int[10];
        int max = 0;
        System.out.println("源数组：");
        for (int i = 0; i < array.length; i++) {
            if (max<array[i]){
                max = array[i];
            }
        }
        System.out.println();
        int[] arr = Arrays.copyOf(array,array.length+1);
        arr[arr.length-1] = max;
        System.out.println("最大值为："+max);
        System.out.println("奖最大值放于数组最后一位的下一位：");
        for (int i : arr){
            System.out.println(i+"\t");
        }
    }

    public static void say(){
        System.out.println("Hi");
    }
    public static void sayHi(String name){
        System.out.println("Hi,my name is "+name);
    }
    public static void sayHello(String name,int age){
        System.out.println("Hi,my name is "+ name+ " and I am "+age+" old");
    }

    public static int getNum(){
        return 1212;
    }
    public static int plus(int a,int b){
        return a+b;
    }
    public static int[] testArray(int len,int max){
        int[] arr1 = new int[len];
        for (int i = 0; i < arr1.length; i++) {
            arr1[i] = (int)(Math.random()*(max+1));
        }
        return arr1;
    }

}
